<template>
	<div :id="id" class="baseContent badgeWhite" v-if="dataRend" v-loading="active">
		   <basetitle>
		   	 <slot slot="left">
		   		 {{dataRend.name}}
		   	 </slot>
			 <div class="child">
			 </div>
		   	  <slot slot="right">
		   			<div class="rightFontCont"><i class="iconfont icon-shuaxin1 rightFont" @click="refreshFull(dataRend.prn)"></i></div>
		   	  </slot>
		   </basetitle>
		   <div class="baseCont">
		   <div class="chartContent overHideen"  :style="{ height: dataRend.itemData.height != '' ? dataRend.itemData.height : defalutHeight }">
			   <multiSelectCharts :itemdata="dataRend.itemData"  :chartType="tabPosition" :id="chartId"/>
		   </div>
		 </div>
	</div>
</template>
<script>
import { generateMixed } from '@/utils/index.js';
import { getFromCache } from '@/utils/cache.js';
const basetitle =()=>import('@/components/basetitle/index.vue')//
const multiSelectCharts =()=>import('@/components/Charts/multiSelectCharts.vue')//多图统计
import store from '../../../store'
import { mapState, mapActions } from 'vuex'
import {getHomePage,refreshContent} from "../../../api/config.js"
export default {
	name: 'multipleChart',
	mixins: [],
	props: {
		className: {
			type: String,
			default: 'baseId' + generateMixed('8')
		},
		id: {
			type: String,
			default: 'baseId' + generateMixed('8')
		},
		width: {
			type: String,
			default: '200px'
		},
		defalutColor: {
			type: String,
			default: 'red'
		},
		itemdata: {
			default: Object
		},
		defalutHeight : {
			type: String,
			default: '300px'
		},
		itemStyle:{
			default: Object
		}
	},
	components: {
		basetitle,
		multiSelectCharts,
	},
	data() {
		return {
			 tabPosition:'line',
			 dataRend:'',
			 active:false,
       chartId:'chart' + generateMixed('8')
		}
	},
	computed: {
		...mapState({
			   mainRend:state => store.state.base.mainRend
		}),
	},
	beforeDestroy(){

	},
	mounted(){
		 this.dataRend=this.itemdata
	},
	methods: {
	...mapActions('base', ['getIndexRend']),
		refreshFull(type){
			let that=this;
			that.active=true;
			let parms={};
			parms.type=type;
      parms.user_prn = JSON.parse(getFromCache('userInfo')).env$user_prn;
			that.$post(refreshContent, parms).then(response => {
				setTimeout(function () {
				that.active=false;
				},2000);
				if (response.status === false){
				  that.$message.error(response.error[0]);
				  return
				}
				  that.dataRend=response.obj
			})
		}
	},
	watch:{
		 mainRend(){
			 this.dataRend=this.mainRend
		 }
	}
}
</script>

<style></style>
